/**
 * @created 05/06/07
 * @author bbrison
 */
package kernel;

import java.util.*;
import java.awt.*;
import objects.Sink;

public class DataInterest extends DataType 
{
    private Sink _sink;
    private int _id;

    public double _startTime ;
    public final static double START_TIME_DEF = 0;
    public final static double START_TIME_MIN = 0;

    //Coordonate of the upper left corner of the covered area
    private double _coordX;
    public final static double COORD_X_MIN = 0.0;
    public final static double COORD_X_DEF = 0.0;
    public double COORD_X_MAX;
    
    private double _coordY;
    public final static double COORD_Y_MIN = 0.0;
    public final static double COORD_Y_DEF = 0.0;
    public double COORD_Y_MAX;

    // Width and length of the covered area
    private double _width;
    public final static double WIDTH_MIN = 0.0;
    public final static double WIDTH_DEF = 0.0;
    public double WIDTH_MAX;
    
    private double _height;
    public final static double HEIGHT_MIN = 0.0;
    public final static double HEIGHT_DEF = 0.0;
    public double HEIGHT_MAX;

    public DataInterest(Sink sink, 
			int id,
			double start,
			double x,
			double y,
			double w,
			double l) {
	setSink(sink);
	setId(id);
	setStartTime(start);
	setCoordX(x);
	setCoordY(y);
	setWidth(w);
	setHeight(l);
    }

    public boolean setSink(Sink sink)
    {
	_sink = sink;
	return true;
    }

    public Sink getSink()
    {
	return _sink;
    }

    public boolean setId(int id)
    {
	_id = id;
	return true;
    }

    public int getId()
    {
	return _id;
    }

    public boolean setStartTime(double startTime){
	boolean done = false;
	if(checkBounds(START_TIME_MIN,UNDEFINED,startTime)){
	    _startTime = startTime;
	    done = true;
	}else{
	    _startTime = START_TIME_DEF;
	}
	return done;
    }
    
    public double getStartTime(){
	return _startTime;
    }
        
    public boolean setCoordX(double x)
    {
	boolean done = false;
	COORD_X_MAX = Simulator.getSimulator().getEnvironment().getSpace().getWidth();
	if(checkBounds(COORD_X_MIN,COORD_X_MAX,x)){
	    _coordX = x;
	    done = true;
	}else{
	    _coordX = COORD_X_DEF;
	}
	return done;
    }
    
    public double getCoordX()
    {
	return _coordX;
    }
    
    public boolean setCoordY(double y)
    {
	boolean done = false;
	COORD_Y_MAX = Simulator.getSimulator().getEnvironment().getSpace().getHeight();
	if(checkBounds(COORD_Y_MIN,COORD_Y_MAX,y)){
	    _coordY = y;
	    done = true;
	}else{
	    _coordY = COORD_Y_DEF;
	}
	return done;
    }
    
    public double getCoordY()
    {
	return _coordY;
    }
    
    public boolean setWidth(double w)
    {
	boolean done = false;
	WIDTH_MAX = Simulator.getSimulator().getEnvironment().getSpace().getWidth();
	if(checkBounds(WIDTH_MIN,WIDTH_MAX,w)){
	    _width = w;
	    done = true;
	}else{
	    _width = WIDTH_DEF;
	}
	return done;
    }
    
    public double getWidth()
    {
	return _width;
    }

    public boolean setHeight(double l)
    {
	boolean done = false;
	HEIGHT_MAX = Simulator.getSimulator().getEnvironment().getSpace().getHeight();
	if(checkBounds(HEIGHT_MIN,HEIGHT_MAX,l)){
	    _height = l;
	    done = true;
	}else{
	    _height = HEIGHT_DEF;
	}
	return done;
    }
    
    public double getHeight()
    {
	return _height;
    }

    public String toString()
    {
	String s = "Id: " + _id;
	s += ";Start time: " + _startTime;
	s += ";x=" + _coordX + " y=" + _coordY + " width=" + _width + " height=" + _height;
	return s;
    }

}
